Skip to content

Conversation

@koriym
Copy link
Member

@koriym koriym commented Nov 10, 2025

Summary

Removes legacy doctrine annotation comments from provider classes to fix AnnotationException when using koriym/attributes with DualReader.

Changes

  • src/RedisProvider.php: Remove @RedisConfig("server") annotation comment
  • src/MemcachedProvider.php: Remove @MemcacheConfig("servers") annotation comment

Details

After migrating to PHP 8 attributes in version 1.5.0, legacy doctrine annotation comments remained in provider class docblocks. These cause AnnotationException when downstream packages using koriym/attributes's DualReader attempt to parse them.

The issue occurs because:

  1. Docblocks contain both legacy @RedisConfig comments and new #[RedisConfig] attributes
  2. DualReader finds @RedisConfig and tries to process it as a doctrine annotation
  3. The RedisConfig class no longer has @Annotation docblock (correctly removed during PHP 8 migration)
  4. Doctrine's AnnotationReader throws AnnotationException

What's Preserved

  • PHP 8 attributes (#[RedisConfig], #[MemcacheConfig])
  • Type hints (@param, @return, @var)
  • Documentation comments (@see, @throws)

Testing

  • composer cs-fix applied successfully
  • Code follows PSR-12 standards

Fixes #33

Summary by Sourcery

Remove legacy Doctrine annotation comments from provider classes to prevent AnnotationException when using DualReader.

Bug Fixes:

  • Remove leftover @RedisConfig annotation comment from RedisProvider.
  • Remove leftover @MemcacheConfig annotation comment from MemcachedProvider.

Summary by CodeRabbit

Refactor

  • Consolidated configuration annotation declarations in provider classes, eliminating redundancy in how configurations are expressed without affecting functionality or public APIs.

This change addresses issue #33 by removing legacy doctrine annotation
comments (@RedisConfig, @MemcacheConfig) from provider class docblocks.

After migrating to PHP 8 attributes in version 1.5.0, these legacy
annotations were causing AnnotationException when packages using
koriym/attributes' DualReader attempted to parse them.

Changes:
- src/RedisProvider.php: Remove @RedisConfig("server") comment
- src/MemcachedProvider.php: Remove @MemcacheConfig("servers") comment

The PHP 8 attributes remain intact and functional. Type hints (@param)
and documentation comments (@see) are preserved.

Fixes #33
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 10, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR removes outdated doctrine annotation comments (@RedisConfig, @MemcacheConfig) from provider class docblocks to prevent AnnotationException in DualReader, while retaining PHP 8 attributes and other docblock tags.

Class diagram for updated provider constructors (RedisProvider, MemcachedProvider)

classDiagram
class RedisProvider {
  +__construct(array server)
  <<attribute>> RedisConfig('server')
}
class MemcachedProvider {
  +__construct(array servers)
  <<attribute>> MemcacheConfig('servers')
}
ProviderInterface <|.. RedisProvider
ProviderInterface <|.. MemcachedProvider
Loading

File-Level Changes

Change Details Files
Removed legacy doctrine annotation comments from provider class docblocks
  • Removed @RedisConfig comment from RedisProvider constructor docblock
  • Removed @MemcacheConfig comment from MemcachedProvider class docblock
src/RedisProvider.php
src/MemcachedProvider.php

Assessment against linked issues

Issue Objective Addressed Explanation
#33 Remove all legacy doctrine annotation comments (e.g., @RedisConfig, @MemcacheConfig) from docblocks in provider classes, specifically src/RedisProvider.php and src/MemcachedProvider.php.
#33 Preserve PHP 8 attributes, type hints, and other documentation comments in provider classes while removing only the legacy annotation comments.
#33 Check all provider classes for legacy annotation comments that correspond to classes in src/Annotation/ and remove them if present.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6bc0cef) to head (b5ea721).
⚠️ Report is 2 commits behind head on 1.x.

Additional details and impacted files
@@             Coverage Diff             @@
##                 1.x       #34   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
  Complexity        38        38           
===========================================
  Files             24        24           
  Lines             90        90           
===========================================
  Hits              90        90           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Removed legacy doctrine annotation comments (@MemcacheConfig and @RedisConfig) from PHPDoc blocks in provider classes while preserving PHP 8 attributes. No changes to method signatures, logic, or control flow.

Changes

Cohort / File(s) Summary
Provider PHPDoc cleanup
src/MemcachedProvider.php, src/RedisProvider.php
Removed legacy @MemcacheConfig and @RedisConfig doctrine annotation comments from PHPDoc blocks above constructors. PHP 8 attributes (#[MemcacheConfig] and #[RedisConfig]) remain unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Straightforward, repetitive cleanup across two files with identical change pattern
  • No logic or signature modifications
  • Documentation-only edits

Poem

🐰 Away with the old annotation dust,
Legacy comments—no longer a must!
PHP 8 attributes shine bright and clean,
The tidiest providers you've ever seen!
Hopping forward with standards so grand! 🌟

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Remove legacy doctrine annotation comments from provider classes' accurately and concisely summarizes the main change in the pull request.
Linked Issues check ✅ Passed The PR successfully removes legacy @RedisConfig and @MemcacheConfig doctrine annotation comments from provider class docblocks while preserving PHP 8 attributes, meeting all requirements in issue #33.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objectives: only legacy annotation comments are removed from two provider files, with no unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-legacy-annotations

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6bc0cef and b5ea721.

📒 Files selected for processing (2)
  • src/MemcachedProvider.php (0 hunks)
  • src/RedisProvider.php (1 hunks)
💤 Files with no reviewable changes (1)
  • src/MemcachedProvider.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Sourcery review
  • GitHub Check: PHPUnit (windows-latest, 8.2, highest)
🔇 Additional comments (1)
src/RedisProvider.php (1)

17-17: LGTM! Verification confirms the migration is complete and correct.

The legacy Doctrine annotations have been successfully removed from RedisProvider.php (line 17) and all related provider classes. Verification confirms:

  • All 3 provider classes properly updated (RedisProvider, MemcachedProvider, LocalCacheProvider)
  • All 6 annotation classes migrated to native PHP 8 attributes with no Doctrine imports
  • Standard PHPDoc tags (@param, @return, etc.) preserved correctly
  • No remaining Doctrine annotation patterns in application code
  • PHP 8 attributes (#[RedisConfig], #[MemcacheConfig], etc.) functioning as intended

The change resolves issue #33 regarding AnnotationException from Doctrine's DualReader when parsing docblocks.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • Consider doing a global search for any remaining legacy Doctrine annotation comments in other classes to prevent similar AnnotationException issues.
  • For consistency, you might standardize the docblock formatting between RedisProvider and MemcachedProvider (e.g., single-line vs multi-line) now that the old annotations are removed.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider doing a global search for any remaining legacy Doctrine annotation comments in other classes to prevent similar `AnnotationException` issues.
- For consistency, you might standardize the docblock formatting between RedisProvider and MemcachedProvider (e.g., single-line vs multi-line) now that the old annotations are removed.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@koriym
Copy link
Member Author

koriym commented Nov 10, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koriym
Copy link
Member Author

koriym commented Nov 10, 2025

@Sourcely I've verified both points:

Global search for legacy annotations

I performed a comprehensive search across the src directory:

grep -r "@(RedisConfig|MemcacheConfig|CacheDir|CacheNamespace)" src/

No other legacy Doctrine annotation comments were found. Only the two files in this PR contained them.

Docblock formatting consistency

The current docblock formatting is already consistent and follows PSR-12 standards:

  • RedisProvider: Single-line docblock (/** @param ... */) - appropriate for simple parameter documentation
  • MemcachedProvider: Multi-line docblock - necessary because it includes both @param and a useful @see reference link

This difference is intentional and semantic. Both formats comply with our coding standards (enforced by phpcbf). If we were to force both to use the same format, we would either:

  1. Lose the valuable @see documentation link, or
  2. Add unnecessary line breaks to RedisProvider's simple docblock

The current approach follows the principle of using multi-line docblocks only when there's multiple types of documentation to include.

@koriym koriym merged commit b79e5e9 into 1.x Nov 10, 2025
54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove legacy doctrine annotation comments from provider classes

2 participants